package com.butioy.study.jersey.mapper;

import com.butioy.study.jersey.model.User;
import javax.ws.rs.ext.Provider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author yanglq
 * @since 3.0.0
 */
@Mapper
public interface UserMapper {

    @Select("select * from t_user where user_id=#{userId}")
    User selectById(@Param("userId") long userId);

    @Select("select * from t_user where account=#{account}")
    User selectByAccount(@Param("account") String account);

    @Insert("insert into t_user(account,pwd,pwd_salt,nick_name,gender,create_time,update_time) values (#{account},#{pwd},#{pwdSalt},#{nickName},#{gender},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    long insert(@Param("user") User user);

}
